<!-- svg图标组件 -->
<template>
  <svg :class="svgClass" aria-hidden="true" :style="{ width: fontSize, height: fontSize }">
    <use :xlink:href="symbolId" :fill="color" />
  </svg>
</template>

<script>
export default {
  props: {
    iconName: { type: String, required: true },
    className: { type: String, default: '' },
    color: { type: String, default: '' },
    fontSize: { type: String, default: '1em' }
  },
  computed: {
    symbolId() {
      return `#${this.iconName}`
    },
    svgClass() {
      return this.className ? `svg-icon ${this.className}` : 'svg-icon'
    }
  }
};
</script>

<style scoped>
.svg-icon {
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>
